use core::fmt::Display;



pub mod encode;
pub mod decode;
pub mod utils;

#[derive(Debug)]
pub enum Error {
    LENGTH,
    INVALID,
    SerdeCustom,
}

impl Display for Error {

    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "{}", match self {
            Error::INVALID => "invalid",
            Error::LENGTH => "length fail",
            Error::SerdeCustom => "serde custom"
        })
    }
}

impl serde::ser::Error for Error {
    
    fn custom<T>(_msg: T) -> Self where T:core::fmt::Display {
        Error::SerdeCustom
    }
}


impl serde::de::Error for Error {

    fn custom<T>(_msg:T) -> Self where T:Display {
        Error::SerdeCustom
    }
}











